using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Voodoo.Sauce.Core;
using Voodoo.Sauce.Internal.IntegrationCheck;
using Voodoo.Sauce.Privacy.UI;

namespace Voodoo.Sauce.Privacy
{
	internal class PrivacyCore : IModule
	{
		public class GdprConsent
		{
			public bool IsGdprApplicable;

			public bool ExplicitConsentGivenForAds;

			public bool ExplicitConsentGivenForAnalytics;

			public bool IsEmbargoedCountry;

			public bool IsAdsEnforcement;

			public bool IsAdjustEnforcement;

			public bool IsVANEnforcement;

			public string CountryCode;

			public override string ToString()
			{
				return $"Applicable: {IsGdprApplicable}, Ads: {ExplicitConsentGivenForAds}, " + $"Analytics: {ExplicitConsentGivenForAnalytics}, Embargoed: {IsEmbargoedCountry}," + $"Ads Enforcement: {IsAdsEnforcement}" + $"Adjust Enforcement: {IsAdjustEnforcement}" + "Country Code: " + CountryCode;
			}
		}

		public class PrivacyManagerParameters
		{
			public PrivacyConfiguration privacyConfiguration;

			public VoodooSettings voodooSettings;

			public Action<GdprConsent> onConsentGiven;

			public Action<GdprConsent> onConsentUpdate;

			public Action<bool> onPrivacyShown;

			public Action onInternetAvailable;

			public Action onGameStarted;

			public Action onGameFinished;

			public Func<bool> hasGameStarted;

			public Action tryOpenDebugger;

			public Action onDeleteDataRequest;

			public IPrivacyCanvas canvas;

			public IRequest request;

			public IPrivacyAPI privacyAPI;

			public IPrivacyUIManager privacyUIManager;
		}

		public const string LIMITED_AD_TRACKING_ID = "00000000-0000-0000-0000-000000000000";

		protected string _idfa = "00000000-0000-0000-0000-000000000000";

		protected bool _adTrackingEnabled;

		protected bool _adsConsent;

		protected bool _analyticsConsent;

		protected bool _isGdprApplicable = true;

		protected bool _isCcpaApplicable;

		protected GdprConsent _gdprConsent;

		protected string _vendorId;

		protected IdfaAuthorizationStatus _idfaAuthorizationStatus;

		public virtual async Task Instantiate(VoodooSettings voodooSettings)
		{
		}

		public virtual List<IntegrationCheckMessage> IntegrationCheck(VoodooSettings settings)
		{
			return null;
		}

		public virtual void Initialize(PrivacyManagerParameters p)
		{
		}

		public virtual bool HasLimitAdTrackingEnabled()
		{
			return !_adTrackingEnabled;
		}

		public virtual string GetAdvertisingId(bool forceZerosForLimitedAdTracking = true)
		{
			return _idfa;
		}

		public virtual string GetVendorId()
		{
			return _vendorId ?? "";
		}

		public virtual bool HasAdsConsent()
		{
			return _adsConsent;
		}

		public virtual bool HasAnalyticsConsent()
		{
			return _analyticsConsent;
		}

		public virtual bool IsGdprApplicable()
		{
			return _isGdprApplicable;
		}

		public virtual bool IsAdsEnforcementEnabled()
		{
			if (_gdprConsent == null)
			{
				return true;
			}
			return _gdprConsent.IsAdsEnforcement;
		}

		public virtual bool IsAdjustEnforcementEnabled()
		{
			if (_gdprConsent == null)
			{
				return true;
			}
			return _gdprConsent.IsAdjustEnforcement;
		}

		public virtual bool IsCcpaApplicable()
		{
			return _isCcpaApplicable;
		}

		public virtual bool UserRequestedToBeForgotten()
		{
			return false;
		}

		internal virtual void OpenPrivacySettings(Action onSettingsClosed = null)
		{
		}

		internal virtual void ShowPrivacyAuthorization()
		{
		}

		public virtual IdfaAuthorizationStatus GetAuthorizationStatus()
		{
			return _idfaAuthorizationStatus;
		}

		internal virtual string GetCmpName()
		{
			return "None";
		}
	}
}
